/**
 *
 */
package com.feizhi.common.search.index.action;

import java.io.IOException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Component;

import com.feizhi.common.search.exception.SearchException;
import com.feizhi.common.search.index.LuceneWork;

/**
 * @author shuaqiu
 */
@Component
public class FlushIndexAction extends AbstractIndexAction implements IndexAction {

    private static final Log LOG = LogFactory.getLog(FlushIndexAction.class);

    @Override
    public void performAction(final LuceneWork work) {
        try {
            LOG.debug("performing flush");
            writer.commit();
            LOG.trace("Index changes committed.");
        } catch (final IOException e) {
            final String message = "Unable to flush index";
            throw new SearchException(message, e);
        }
    }

}
